package com.doubleview.hutool;

import cn.hutool.core.map.MapUtil;
import cn.hutool.core.math.MathUtil;
import cn.hutool.core.math.Money;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * @author huchengchao <huchengchao@kuaishou.com>
 * Created on 2021-11-29
 */
public class NumberUtils {

    public static Map<String, String> fillNullValue(Map<String, String> map) {
        Map<String, String> result = new HashMap<>(4);
        if (MapUtil.isEmpty(map)) {
            return result;
        }
        for (Map.Entry<String, String> entry : map.entrySet()) {
            result.put(entry.getKey(), StrUtil.blankToDefault(entry.getValue(), ""));
        }
        return result;
    }

    public static void main(String[] args) {
        double a = 10d / 3d;
        System.out.println(TimeUnit.MINUTES
                .toMillis(0));
        System.out.println(NumberUtil.isNumber("0.10"));
        System.out.println(new Money(new BigDecimal("0.236"), RoundingMode.DOWN).getCent());
        System.out.println(MathUtil.centToYuan(100));
        System.out.println(NumberUtil.mul("100", "3.5", "0.01").longValue());
        System.out.println(NumberUtil.div(3.58 * 100, 100, 2));
        Map<String, String> map = new HashMap<>();
        map.put("a", "a");
        map.put("b", null);
        Map<String, String> result = fillNullValue(map);
        System.out.println(fillNullValue(map));
    }
}
